#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <float.h> 
#include <assert.h>


#define BUFSIZE 1024
#define ID_TAB 7
#define ID_INT 4
#define RO_INT 5
#define RO_FLOAT 6
#define ID_FLOAT 1
#define ID_VOID 2
#define NOINIT 3

#ifdef DBL_DECIMAL_DIG 
#define OP_DBL_Digs (DBL_DECIMAL_DIG) 
#else 
#ifdef DECIMAL_DIG 
#define OP_DBL_Digs (DECIMAL_DIG) 
#else 
#define OP_DBL_Digs (DBL_DIG + 3) 
#endif 
#endif 

  FILE *driver;
	
  extern int yylineno;
  int yylex ();
  int yyerror ();
  char elseDrive[20000];
  char tmpC[200];
  int tabHash[BUFSIZE];
  char n_reg[BUFSIZE];
  char tabFonction[BUFSIZE][BUFSIZE];
  char tabFonctionNom[BUFSIZE][BUFSIZE];
  int tmp;
  int pos;
  float posf;
  int glob_type = 0;
  int glob_fonction = 0;
  int static_var[5];
  char affecType[200];
  int affect = 0;

  int new_reg(){
    static int i = 0;
    i++;
    return i%BUFSIZE;
  }
	
  int hash(char *s){
    int r=0;
    while(s[0] != '\0'){
      r+=s[0];
      s++;
    }
    return(r%BUFSIZE);
  }

  char * translate(int i){
    if (i==ID_INT)
      return "i32";
    else if (i==ID_FLOAT)
      return "float";
    else if (i==ID_VOID)
      return "void";
    else
      return "erreur";
  }

  int in_static_array(char *input){
    char *temp[] = {"%gear","%accelCmd","%steer","%clutchCmd","%brakeCmd"};
    int i=0;
    for(i=0;i<5;i++){
      if(strcmp(input, temp[i])==0){
	return i;
      }
    }
    return -1;
  }

  void ajout_store_manquant(){
    char *temp[] = {"store i32 1, i32* %gear","store float 0.000000e+00, float* %accelCmd","store float 0.000000e+00, float* %steer","store float 0.000000e+00, float* %clutchCmd","store float 0.000000e+00, float* %brakeCmd"};
    int i=0;
    strcpy(tmpC, "");
    for(i=0;i<5;i++){
      if(static_var[i]==0){
	strcat(tmpC, temp[i]);
	strcat(tmpC, "\n");
      }
    }
    return;
  }

char* codeReg(char * reg, char * code){
  if(strcmp(reg, "")==0)
    return code; 
  else 
    return reg;
}

char* postCodeReg(char* reg, char* code){
  if(strcmp(reg, "")==0)
    return "";
  else
    return code;
}

char** str_split(char* a_str, const char a_delim)
{
    char** result    = 0;
    size_t count     = 0;
    char* tmp        = a_str;
    char* last_comma = 0;
    char delim[2];
    delim[0] = a_delim;
    delim[1] = 0;

    while (*tmp){
        if (a_delim == *tmp){
            count++;
            last_comma = tmp;
        }
        tmp++;
    }
    count += last_comma < (a_str + strlen(a_str) - 1);
    count++;
    result = malloc(sizeof(char*) * count);
    if (result){
        size_t idx  = 0;
        char* token = strtok(a_str, delim);
        while (token){
            assert(idx < count);
            *(result + idx++) = strdup(token);
            token = strtok(0, delim);
        }
        assert(idx == count - 1);
        *(result + idx) = 0;
    }
    return result;
}

void parse_arg_list(char* input)
{
    char** tokens;
    char temp[200] = "";
    tokens = str_split(input, ',');
    if (tokens){
        int i;
        for (i = 0; *(tokens + i); i++){
            if (*(tokens+i)[0] == 'i')
                strcat(temp, ", i32");
            else if (*(tokens+i)[0] == 'f')
                strcat(temp, ", float");  
            free(*(tokens + i));
        }
        strcpy(tmpC, temp+2);
        free(tokens);
    }
}

void allExceptDrive(){
  fprintf(driver,"target triple = \"x86_64-unknown-linux-gnu\"\n");

  fprintf(driver,"%%struct.CarElt = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.tInitCar,\n");
  fprintf(driver,"    %%struct.tPublicCar,\n");
  fprintf(driver,"    %%struct.tCarRaceInfo,\n");
  fprintf(driver,"    %%struct.tPrivCar,\n");
  fprintf(driver,"    %%struct.tCarCtrl,\n");
  fprintf(driver,"    %%struct.tCarPitCmd,\n");
  fprintf(driver,"    %%struct.RobotItf*,\n");
  fprintf(driver,"    %%struct.CarElt*\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tInitCar = type {\n");
  fprintf(driver,"    [32 x i8],\n");
  fprintf(driver,"    [32 x i8],\n");
  fprintf(driver,"    [32 x i8],\n");
  fprintf(driver,"    [32 x i8],\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [3 x float],\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    [4 x %%struct.tWheelSpec],\n");
  fprintf(driver,"    %%struct.tVisualAttributes\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.t3Dd = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tWheelSpec = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tVisualAttributes = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [2 x %%struct.t3Dd],\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tPublicCar = type {\n");
  fprintf(driver,"    %%struct.tDynPt,\n");
  fprintf(driver,"    %%struct.tDynPt,\n");
  fprintf(driver,"    [4 x [4 x float]],\n");
  fprintf(driver,"    %%struct.tTrkLocPos,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [4 x %%struct.tPosd]\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tDynPt = type {\n");
  fprintf(driver,"    %%struct.tPosd,\n");
  fprintf(driver,"    %%struct.tPosd,\n");
  fprintf(driver,"    %%struct.tPosd\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tPosd = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tTrkLocPos = type {\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.trackSeg = type {\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    [4 x %%struct.t3Dd],\n");
  fprintf(driver,"    [7 x float],\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.SegExt*,\n");
  fprintf(driver,"    %%struct.trackSurface*,\n");
  fprintf(driver,"    [2 x %%struct.trackBarrier*],\n");
  fprintf(driver,"    %%struct.RoadCam*,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%union.anon.0\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.SegExt = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32*\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.trackSurface = type {\n");
  fprintf(driver,"    %%struct.trackSurface*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.trackBarrier = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.trackSurface*,\n");
  fprintf(driver,"    %%class.v2t\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%class.v2t = type {\n");
  fprintf(driver,"    %%union.anon\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%union.anon = type {\n");
  fprintf(driver,"    %%struct.anon\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.anon = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.RoadCam = type {\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.RoadCam*\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%union.anon.0 = type {\n");
  fprintf(driver,"    %%struct.anon.1\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.anon.1 = type {\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSeg*\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCarRaceInfo = type {\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    i8,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    %%struct.TrackOwnPit*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.CarPenaltyHead\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.TrackOwnPit = type {\n");
  fprintf(driver,"    %%struct.tTrkLocPos,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [4 x %%struct.CarElt*]\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.CarPenaltyHead = type {\n");
  fprintf(driver,"    %%struct.CarPenalty*,\n");
  fprintf(driver,"    %%struct.CarPenalty**\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.CarPenalty = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.anon.2\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.anon.2 = type {\n");
  fprintf(driver,"    %%struct.CarPenalty*,\n");
  fprintf(driver,"    %%struct.CarPenalty**\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tPrivCar = type {\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [32 x i8],\n");
  fprintf(driver,"    [4 x %%struct.tWheelState],\n");
  fprintf(driver,"    [4 x %%struct.tPosd],\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    [10 x float],\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [4 x float],\n");
  fprintf(driver,"    [4 x float],\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.tCollisionState_\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tWheelState = type {\n");
  fprintf(driver,"    %%struct.tPosd,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCollisionState_ = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [3 x float],\n");
  fprintf(driver,"    [3 x float]\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCarCtrl = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [4 x [32 x i8]],\n");
  fprintf(driver,"    [4 x float],\n");
  fprintf(driver,"    i32\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCarPitCmd = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.tCarPitSetup\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCarPitSetup = type {\n");
  fprintf(driver,"    %%struct.tCarPitSetupValue,\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    %%struct.tCarPitSetupValue,\n");
  fprintf(driver,"    %%struct.tCarPitSetupValue,\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [4 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [8 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [2 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x %%struct.tCarPitSetupValue],\n");
  fprintf(driver,"    [3 x i32]\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tCarPitSetupValue = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.RobotItf = type {\n");
  fprintf(driver,"    void (i32, %%struct.tTrack*, i8*, i8**, %%struct.Situation*)*,\n");
  fprintf(driver,"     {}*,\n");
  fprintf(driver,"     {}*,\n");
  fprintf(driver,"     {}*,\n");
  fprintf(driver,"     i32 (i32, %%struct.CarElt*, %%struct.Situation*)*,\n");
  fprintf(driver,"     void (i32)*,\n");
  fprintf(driver,"     i32\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tTrack = type {\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.tTrackPitInfo,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSurface*,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.t3Dd,\n");
  fprintf(driver,"    %%struct.tTrackGraphicInfo\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tTrackPitInfo = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.trackSeg*,\n");
  fprintf(driver,"    %%struct.TrackOwnPit*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tTrackGraphicInfo = type {\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i8*,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    [3 x float],\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i8**,\n");
  fprintf(driver,"    %%struct.tTurnMarksInfo\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.tTurnMarksInfo = type {\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float,\n");
  fprintf(driver,"    float\n");
  fprintf(driver,"}\n");

  fprintf(driver,"\n");

  fprintf(driver,"%%struct.Situation = type {\n");
  fprintf(driver,"    %%struct.tRaceAdmInfo,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    double,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    %%struct.CarElt**\n");
  fprintf(driver,"}\n\n");

  fprintf(driver,"%%struct.tRaceAdmInfo = type {\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i32,\n");
  fprintf(driver,"    i64\n");
  fprintf(driver,"}\n\n");

}


void declarations(){
  int declar = 0; int nom = 0; int cmpt = 0;
  for(declar = 0; declar < glob_fonction; declar++){
    cmpt = 0;
    for(nom = declar; nom < glob_fonction; nom++){
      if(strcmp(tabFonctionNom[declar], tabFonctionNom[nom])==0)
  cmpt++;
    }
    if(cmpt <= 1){
      fprintf(driver, "%s", tabFonction[declar]);
      fprintf(driver, "\n");
    }
  }
  //fprintf(driver,"declare float @test_fonction(float %%a, float %%b)\n");
  //fprintf(driver,"declare float @norm_pi_pi(float %%a)\n");
  fprintf(driver,"declare float @get_track_angle(%%struct.tTrkLocPos*)\n");
  fprintf(driver,"declare float @get_pos_to_right(%%struct.tTrkLocPos*)\n");
  fprintf(driver,"declare float @get_pos_to_middle(%%struct.tTrkLocPos*)\n");
  fprintf(driver,"declare float @get_pos_to_left(%%struct.tTrkLocPos*)\n");
  fprintf(driver,"declare float @get_pos_to_start(%%struct.tTrkLocPos*)\n");
  fprintf(driver,"declare float @get_track_seg_length(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_width(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_start_width(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_end_width(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_radius(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_right_radius(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_left_radius(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_track_seg_arc(%%struct.trackSeg*)\n");
  fprintf(driver,"declare %%struct.trackSeg* @get_track_seg_next(%%struct.trackSeg*)\n");
  fprintf(driver,"declare float @get_car_yaw(%%struct.CarElt*)\n");

}


void static_declarations(){
  tabHash[hash("%gear")] = ID_INT;
  tabHash[hash("%accelCmd")] = ID_FLOAT;
  tabHash[hash("%steer")] = ID_FLOAT;
  tabHash[hash("%clutchCmd")] = ID_FLOAT;
  tabHash[hash("%brakeCmd")] = ID_FLOAT;
  tabHash[hash("%x")] = RO_FLOAT;
  tabHash[hash("%y")] = RO_FLOAT;
  tabHash[hash("%z")] = RO_FLOAT;
  tabHash[hash("%speedx")] = RO_FLOAT;
  tabHash[hash("%speedy")] = RO_FLOAT;
  tabHash[hash("%speedz")] = RO_FLOAT;
  tabHash[hash("%accelx")] = RO_FLOAT;
  tabHash[hash("%accely")] = RO_FLOAT;
  tabHash[hash("%accelyz")] = RO_FLOAT;
  tabHash[hash("%rpm")] = RO_INT;
  int i=0;
  for (i = 0; i < 5; ++i) {
    static_var[i] = 0;
  }
}

void init_hash(){
  int i;
  for (i = 0; i < BUFSIZE; ++i)
    {
      tabHash[i] = NOINIT;
    }
}
